package com.invokestatic.shooter.Entity;

import java.util.ArrayList;
import java.util.Arrays;

import com.invokestatic.shooter.Art;
import com.invokestatic.shooter.Input;
import com.invokestatic.shooter.Level.Camera;
import com.invokestatic.shooter.Screens.Screen;

public class Player extends Entity {

	public int tick = 0;
	private double speed = 0.7;
	private double rotation = 0;
	public double xp, yp;

	public Player(int x, int y) {
		this.xp = x;
		this.yp = y;
		speed = 1;
		
	}

	@Override
	public void render(Screen g, Camera camera) {
		g.draw(Art.players[0][1][1], (int)xp, (int)yp, (float) rotation, 1.5f, 1.5f);
	}

	@Override
	public void tick(Input input) {
		
		if((input.buttons[Input.UP] || input.buttons[Input.DOWN]) && (input.buttons[Input.LEFT] || input.buttons[Input.RIGHT])) {
			speed = (0.8) * (Math.sqrt(2) / 2.0);
		} else {
			speed = (0.8);
		}
		
		/* BEGIN MOVEMENT */
		if(input.buttons[Input.UP]) {
			ya += speed;
		}
		if(input.buttons[Input.DOWN]) {
			ya -= speed;
		}
		if(input.buttons[Input.LEFT]) {
			xa += speed;
		}
		if(input.buttons[Input.RIGHT]) {
			xa -= speed;
		}
		
		//TODO Collision
		
		xp -= xa;
		yp -= ya;
		xa *= 0.7;
		ya *= 0.7;
		/* END MOVEMENT */
		
		
		
		
		tick++;
		
	}

	private void shoot() {
//		entities.add(new Bullet(1280/2, 720/2, Math.cos(Math.toRadians(this.rotation-90)), Math.sin(Math.toRadians(this.rotation-90))));
	}

}
